/**
 * Created by Administrator on 2015/12/9.
 *
 * web 项目测试
 */

var http=require("http");
var url=require('url');
var fs=require('fs');
var path=require('path');

var ROOT='D:/IdeaProjects/Node/node_demo/app_web';
http.createServer(function(request,response){
    //处理请求
    var pathname=url.parse(request.url).pathname;
     fs.readFile(path.join(ROOT,pathname),function(err,file){
         if(err){
             response.writeHead(404);
             response.end('no page found ');
             return;
         }
         response.writeHead(200);
         response.end(file);
     });

    //响应
  //  response.writeHead(200,{'Content-Type':'text/plain'});
  //  response.end('hello world\n');

}).listen(3000,'127.0.0.1');

console.log('server listen at 127.0.0.1:3000');
